/* 
    应用中心,应用管理,管理详细,获取pod 事件
 */

<template>
    <div>
        <div style="padding-top:10px;padding-left:5px;text-align: left;">
            <el-form :inline="true" class="demo-form-inline">
                <el-form-item label="应用实例">
                    <el-select @change="getPodEvents" style="width:300px;" v-model="podName" placeholder="请选择应用实例">
                        <el-option v-for="item in podNames" :key="item" :label="item" :value="item">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item>
                    <el-button icon="el-icon-refresh" @click="getPodEvents" type="primary">刷新</el-button>
                </el-form-item>
            </el-form>
        </div>
        <el-table :data="podEventsDataLis" 
            v-loading="loadingTable" 
            highlight-current-row 
            style="width: 100%;">	
            <el-table-column prop="message" label="消息" ></el-table-column>
            <el-table-column  prop="count"  label="总数" ></el-table-column>
            <el-table-column  prop="firstTimestamp"  label="第一次出现" ></el-table-column>
            <el-table-column  prop="lastTimestamp"  label="最后一次出现" ></el-table-column>
        </el-table>
    </div>
    
</template>

<script>
export default {
    data() {
        return {
            loadingTable: false,
            podEventsDataLis: [],
            podName: ''
        }
    },
    props: [
        'podNames',
    ],
    methods: {
        // 获取pod 列表
        getPodEvents() {
            // 当前空间名称
            const namespace = this.userBaseInfo.getCurrentSelectedNamespace();
            // 当前实例名称
            const podName = this.podName;

            if (namespace != '' && typeof namespace != undefined && podName != '' && typeof podName != undefined) {
                let geteventUrl = this.projectConfig.URL_API_APP_MANAGE_POD_EVENTS + '/' + namespace + '/' + podName;
                this.loadingTable = true;
                this.httpClient.httpClientget(geteventUrl,'').then(res => {
                    this.loadingTable = false;
                    this.podEventsDataLis = res.data;
                });
            }

        }
    }
};
</script>

<style>

</style>
 